<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        * {
            margin: 0 auto;

        }

        #mask {
            width: 3000px;
            height: 3000px;
            background-color: grey;
            position: absolute;
        }

        #box {
            width: 1024px;
            height: 800px;
            position: absolute;
            top: 50px;
            left: 100px;
            background-color: white;
            border: 2px dashed white;
        }

        a img {
            width: 30px;
            height: 60px;
        }

        .left {
            width: 30px;
            height: 60px;
            position: absolute;
            left: 0px;
            top: 45%;
        }

        .right {
            width: 30px;
            height: 60px;
            position: absolute;
            right: 0px;
            top: 45%;
        }

        .pc {
            width: 700px;
            height: 468px;
        }
    </style>
</head>

<body>
    <div id="mask">
        <div id="box">
            <h3>
                这个是一个example
            </h3>
            <img class="pc" :src=imgArr[index] alt="">
            <a href="javascript:void(0)" @click="prev" class="left" v-show="index!=0">
                <img src="./pic/prev.jpg" alt="">
            </a>
            <a href="javascript:void(0)" @click="next" class="right" v-show="index!=5">
                <img src="./pic/next.jpg" alt="">
            </a>


        </div>
    </div>

    <script>
        var i = this.index;
        var mask = new Vue({
            el: "#mask",
            data: {
                imgArr: [
                    "./pic/01.jpg",
                    "./pic/02.jpg",
                    "./pic/03.jpg",
                    "./pic/04.jpg",
                    "./pic/05.jpg",
                    "./pic/06.jpg",
                ],
                index: 0
            },
            methods: {
                prev: function () {
                    if (this.index > 0) {
                        this.index--
                    } else {
                        alert("no photos");
                    }
                },
                next: function () {
                    if (this.index < 5) {
                        this.index++;
                    } else {
                        alert("别扯了，到底了");
                    }
                }

            }
        })
    </script>
</body>

</html>